<script>
import store from "./store/index";
export default {
	onLaunch: function () {
		uni.getSystemInfo({
			success: (res) => {
				let menuButtonInfo = {};
				if (res.platform === "ios") {
					// ios设备的胶囊按钮都是固定的
					menuButtonInfo = {
						width: 87,
						height: 32,
						left: res.screenWidth - 7 - 87,
						right: res.screenWidth - 7,
						top: res.statusBarHeight + 4,
						bottom: res.statusBarHeight + 4 + 32,
					};
				} else {
					// 安卓通过api获取
					menuButtonInfo = uni.getMenuButtonBoundingClientRect();
				}
				// 导航栏高度 = 状态栏到胶囊的间距（胶囊距上未知-状态栏高度）* 2 + 胶囊高度 + 状态栏高度
				let navHeight =
					(menuButtonInfo.top - res.statusBarHeight) * 2 +
					menuButtonInfo.height +
					res.statusBarHeight;
				// 按钮上下边距高度
				let menuBottom = menuButtonInfo.top - res.statusBarHeight;
				// 导航栏右边到屏幕边缘的距离
				let menuRight = res.screenWidth - menuButtonInfo.right;
				// 导航栏高度
				let menuHeight = menuButtonInfo.height;
				let navInfo = {
					navHeight,
					menuBottom,
					menuRight,
					menuHeight,
				};
				store.state.navInfo = navInfo;
			},
			fail(err) { },
		});
	},
	onShow: function () { },
	onHide: function () { }
}
</script>

<style>
@import "./static/css/base.css";
</style>
